# coding:utf-8

"""
tf_demo06_define_addLayer_for_demo10
Created on 2016/12/9 16:28
@author: GuoYufu
@group : OceanHorn
@contact: OceanHorn@163.com
"""

import tensorflow as tf

def add_layer(inputs, in_size, out_size, activation_function=None):

    with tf.name_scope('weights'):
        weights = tf.Variable(
            initial_value=tf.random_normal(shape=[in_size, out_size])
        )
    with tf.name_scope('biases'):
        biases = tf.Variable(
            tf.zeros([1, out_size]) + 0.1
        )
    with tf.name_scope('layer_output'):
        wx_plus_b = tf.matmul(inputs, weights) + biases

    if activation_function is None:
        outputs = wx_plus_b
    else:
        outputs = activation_function(wx_plus_b)
    return outputs